package com.wnzt.baszh.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wnzt.baszh.entity.TbasxMx;
import com.wnzt.baszh.service.IDicService;

@Controller
@RequestMapping("/dic")
public class DicController {

	@Autowired
	private IDicService dic;
	
	private List<TbasxMx> list = new ArrayList<TbasxMx>();
	
	/**
	 * ICD编码
	 * @author [lv tang wei]
	 * Describe:
	 * @param request
	 * @return
	 * [2017年6月9日]
	 */
	@RequestMapping("/findICD11code")
	@ResponseBody
	public Object findICD11code(HttpServletRequest request) {
		int num = Integer.parseInt(request.getParameter("page"));
		int size = Integer.parseInt(request.getParameter("rows"));// 每页多少行
		String value = request.getParameter("q");
		return dic.findICD11code(value, num, size);
	}
	
	@RequestMapping("/getItemValue")
	@ResponseBody
	public Object getItemVale(HttpServletRequest request) {
		String code = request.getParameter("code");
		for (int i = 0; list != null && i < list.size(); i++) {
			TbasxMx mx = list.get(i);
			if (mx.getFitemcode().trim().equals(code.trim())) {
				return mx;
			}
		}
		return null;
	}
	
	@RequestMapping("/findTOPERATET")
	@ResponseBody
	public Object findTOPERATET(HttpServletRequest request) {
		int num = Integer.parseInt(request.getParameter("page"));
		int size = Integer.parseInt(request.getParameter("rows"));// 每页多少行
		String value = request.getParameter("q");
		return dic.findTOPERATET(value, num, size);
	}
	
	@RequestMapping("/findStandardByCode")
	@ResponseBody
	public Object findStandardByCode(HttpServletRequest request) {
		String code = request.getParameter("code");
		return dic.findStandardByCode(code);
	}
	
	@RequestMapping("/findTworkroom")
	@ResponseBody
	public Object findTworkroom(HttpServletRequest request) {
		return dic.findTworkroom();
	}
	
	@RequestMapping("/setItemVale")
	@ResponseBody
	public Object setItemVale(HttpServletRequest request) {
		return true;
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping("/findBambMx")
	@ResponseBody
	public Object findBambMx(HttpServletRequest request) {
		String mainid=request.getParameter("mainid");
		list.clear();		
		list=dic.findBambMx(mainid);
		return list;
	}
}
